#include <iostream>
#include <SDL/SDL.h>
#include "UserAction.h"

using namespace std;
using namespace JDL;

UserAction::UserAction(Input *in, Drawable *obj) : Action(obj)
{
  _in = in;
}

UserAction::~UserAction()
{

}

void	UserAction::Do()
{
  SDL_Rect	rect;

  rect = _obj->GetPosition();
  if (_in->IsKeyDown(SDLK_UP))
    rect.y -= 2;
  else if (_in->IsKeyDown(SDLK_DOWN))
    rect.y += 2;
  else if (_in->IsKeyDown(SDLK_LEFT))
    rect.x -= 2;
  else if (_in->IsKeyDown(SDLK_RIGHT))
    rect.x += 2;
  _obj->SetPosition(rect.x, rect.y);
}
